package hsh.sun;
import java.util.Date;
public class Account {
    private String id, name;
    private double banlance;
    private Date date;

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public double getBanlance() {
        return banlance;
    }

    public Date getDate() {
        return date;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setBanlance(double banlance) {
        this.banlance = banlance;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    //    全参构造器
    public Account(String id, String name, double banlance) {
        this.name = name;
        this.banlance = banlance;
        this.id = id;
        this.date = new Date();

    }

    //    空参构造器
    public Account() {
        this.name = "";
        this.banlance = 0;
        this.id = "";
        this.date = new Date();
    }

    //   取钱的方法
    public void withdraw(double money) {
        if (this.banlance < money) {
            System.out.println("您的余额不足：");
            return;
        }
        this.banlance = this.banlance - money;
    }

    //    存钱的方法
    public void deposite(double money) {
        this.banlance = this.banlance + money;

    }
//转账给他人的方法
    public  void zhaun_zhang(Account other,double money){
        if(this.banlance<money){
            System.out.println("账户余额不足，无法完成转账");
            return;
        }
       this.banlance=this.banlance-money;
        other.banlance=other.banlance+money;
    }
    public void print(){
        System.out.println("账号："+id+"名字："+name+"存款余额："+banlance);
    }
}
